package leetcodecompetition.S109;

import org.junit.jupiter.api.Test;

/**
 * @Author: Siantar
 * @Date: 2023-07-22-22:32
 * @Description: 1.0
 */
public class T6930 {
    public boolean isGood(int[] nums) {
        int n = nums.length - 1;
        if (n == 0) return false;
        int[] bs = new int[n];
        for (int num : nums) {
            if (1 <= num && num <= n) {
                bs[num - 1]++;
            } else {
                return false;
            }
        }
        for (int i = 0; i < n - 1; i++) {
            if (bs[i] != 1) return false;
        }
        if (bs[n - 1] != 2) return false;
        return true;
    }

    @Test
    public void test() {
        System.out.println(isGood(new int[]{1,2,3,3}));
    }
}
